Socket
Socket
Sign inDemoInstall

@thi.ng/api

Package Overview
Dependencies
0
Maintainers
1
Versions
178
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @thi.ng/api

Common, generic types, interfaces & mixins


Version published
Weekly downloads
132K
decreased by-1.31%
Maintainers
1
Install size
121 kB
Created
Weekly downloads
 

Package description

What is @thi.ng/api?

@thi.ng/api is a collection of TypeScript interfaces, types, and utility functions for functional programming, event handling, and other common tasks in JavaScript/TypeScript projects.

What are @thi.ng/api's main functionalities?

Event Handling

This feature allows you to create and manage custom events. The code sample demonstrates creating an event, adding a listener, and dispatching the event.

const { Event } = require('@thi.ng/api');

const event = new Event('test');
event.addListener('test', (e) => console.log('Event received:', e));
event.dispatch('test', { message: 'Hello, World!' });

Functional Programming Utilities

This feature provides utility functions for functional programming. The code sample demonstrates filtering an array to get even numbers and then mapping the array to get their squares.

const { map, filter } = require('@thi.ng/api');

const nums = [1, 2, 3, 4, 5];
const evenNums = filter((x) => x % 2 === 0, nums);
const squaredNums = map((x) => x * x, evenNums);
console.log(squaredNums); // [4, 16]

Type Utilities

This feature includes type-checking utilities. The code sample demonstrates checking if a value is a string or a number.

const { isString, isNumber } = require('@thi.ng/api');

console.log(isString('hello')); // true
console.log(isNumber(123)); // true
console.log(isNumber('123')); // false

Other packages similar to @thi.ng/api

Readme

Source

@thi.ng/api

npm version npm downloads Mastodon Follow

[!NOTE] This is one of 192 standalone projects, maintained as part of the @thi.ng/umbrella monorepo and anti-framework.

🚀 Please help me to work full-time on these projects by sponsoring me on GitHub. Thank you! ❤️

About

Common, generic types, interfaces & mixins.

This package is implicitly used by most other projects in this repository. It defines:

  • Dozens of generic, common interfaces & types
  • Class & method decorators
  • Mixins
  • Typedarray utilities

Status

STABLE - used in production

Search or submit any issues for this package

Installation

yarn add @thi.ng/api

ESM import:

import * as api from "@thi.ng/api";

Browser ESM import:

<script type="module" src="https://esm.run/@thi.ng/api"></script>

JSDelivr documentation

For Node.js REPL:

const api = await import("@thi.ng/api");

Package sizes (brotli'd, pre-treeshake): ESM: 2.41 KB

Dependencies

None

API

Generated API docs

Authors

If this project contributes to an academic publication, please cite it as:

@misc{thing-api,
  title = "@thi.ng/api",
  author = "Karsten Schmidt and others",
  note = "https://thi.ng/api",
  year = 2016
}

License

© 2016 - 2024 Karsten Schmidt // Apache License 2.0

Keywords

FAQs

Last updated on 08 May 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc